#define  _CRT_SECURE_NO_WARNINGS


#include<stdio.h>


int main()
{
    int row = 0, col = 0, t = 1;
    while (scanf("%d %d", &row, &col) != EOF)
    {
        if (row == 0 && col == 0)
            break;
        printf("Field #%d:\n", t++);
        char arr[100][101] = { 0 };
        int i = 0, j = 0, sum = 0;
        for (i = 0; i < row; i++)
        {
            scanf("%s", arr[i]);
        }
        for (i = 0; i < row; i++)
        {
            for (j = 0; j < col; j++)
            {
                if (arr[i][j] != '*')
                {
                    sum = 0;
                    if (arr[i - 1][j - 1] == '*')
                        sum++;
                    if (arr[i - 1][j] == '*')
                        sum++;
                    if (arr[i - 1][j + 1] == '*')
                        sum++;
                    if (arr[i][j + 1] == '*')
                        sum++;
                    if (arr[i + 1][j + 1] == '*')
                        sum++;
                    if (arr[i + 1][j] == '*')
                        sum++;
                    if (arr[i + 1][j - 1] == '*')
                        sum++;
                    if (arr[i][j - 1] == '*')
                        sum++;
                    arr[i][j] = sum + '0';
                }
            }
            puts(arr[i]);
        }
        printf("\n");
    }

    return 0;
}